package where2go.sctu.com.zhiyou.adpater;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * ProjectName: zhiyou
 * PackageName: where2go.sctu.com.zhiyou.adpater
 * Created by 张某人
 * CreatedTime:on 2018/5/13   16:39
 * Description:
 */

public class DetailPagerAdapter extends FragmentStatePagerAdapter {

    private List<Fragment> fragments = new ArrayList<>();
    private List<String> titles = new ArrayList<>();

    public DetailPagerAdapter(FragmentManager fm) {
        super(fm);
    }


    public void addTab(Fragment fragment, String title) {
        fragments.add(fragment);
        titles.add(title);
    }
    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
